#ifndef __I_DYNAMIC_SCENE_OBJECT_H_INCLUDED__
#define __I_DYNAMIC_SCENE_OBJECT_H_INCLUDED__
#include "IGameObject.h"
namespace irr
{
	namespace scene
	{
		class IAnimatedMesh;
	}
	namespace video
	{
		class ITexture;
	}
}

namespace game
{
	namespace scene
	{
		struct SAnimationEntry
		{
		public:
			u32 startFrame;
			u32 endFrame;
			irr::core::stringc Name;

			SAnimationEntry(const c8* name, u32 startFrame, u32 endFrame)
				:	startFrame(startFrame),
					endFrame(endFrame),
					Name(name)
			{
			}

			virtual ~SAnimationEntry()
			{
			}
		};


		struct SMeshEntry
		{
		public:
			irr::core::stringc Name;
			irr::core::stringc File;
			irr::scene::IAnimatedMesh* Mesh;
			bool Established;

			SMeshEntry(const c8* name, const c8* file)
				:	Name(name),
					File(file),
					Established(false),
					Mesh(0)
			{
			}

			virtual ~SMeshEntry()
			{
			}
		};

		struct STextureEntry
		{
		public:
			irr::core::stringc Name;
			irr::core::stringc File;
			irr::video::ITexture* Texture;
			bool Established;

			STextureEntry(const c8* name, const c8* file)
				:	Name(name),
					File(file),
					Established(false),
					Texture(0)
			{
			
			}

			virtual ~STextureEntry()
			{
			}
		};


		struct SDynamicObjectEntry : public SGameObjectEntry
		{
		public:
			SDynamicObjectEntry()
			{
			};
			virtual ~SDynamicObjectEntry()
			{
			}

			irr::core::map<irr::core::stringc, SMeshEntry*> Meshes;
			irr::core::map<irr::core::stringc, STextureEntry*> Textures;
			irr::core::map<irr::core::stringc, SAnimationEntry*> Animations;
		};


		//! Class represents a dynamic object on scene
		class IDynamicObject : public IGameObject
		{
		public:
			
			//! Default constructor
			IDynamicObject(SDynamicObjectEntry* entry, irr::scene::ISceneManager* sceneManager, game::video::IVideoHandler* videoHandler) 
				:	IGameObject(entry, sceneManager, videoHandler),
					TypedEntry(entry)
			{
				if(TypedEntry)
					TypedEntry->grab();
			}

			//! Destructor 
			virtual ~IDynamicObject()
			{
					if(TypedEntry)
					TypedEntry->drop();
			}

			//! Adds named mesh to scene object
			virtual void addMesh(const c8* name, irr::scene::IAnimatedMesh* mesh) = 0; 

			//! Adds named mesh to scene object from file
			virtual void addMesh(const c8* name, const c8* file) = 0;

			//! Adds texture
			virtual void addTexture(const c8* name, irr::video::ITexture* texture) = 0;

			//! Adds texture from file
			virtual void  addTexture(const c8* name, const c8* file) = 0;

			//! Gets animation by name
			virtual SAnimationEntry* getAnimationInfo(const c8* name) = 0;

			//! Adds animation to object
			virtual void addAnimationInfo(const c8* name, SAnimationEntry* animation) = 0;

		protected:
			SDynamicObjectEntry* TypedEntry;
		};
	}
}
#endif